package com.gc.server.controller.api;

import com.gc.server.entity.BookEntity;
import com.gc.server.entity.BookTypeEntity;
import com.gc.server.service.BookService;
import com.gc.server.service.BookTypeService;
import com.gc.server.service.SaleRecordService;
import com.yf.annotation.IgnoreAuth;
import com.yf.annotation.LoginUserId;
import com.yf.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/sale")
public class ApiSaleController {

    @Autowired
    private SaleRecordService recordService;

    //月份统计
    @GetMapping("/list")
    public R month(Date startDate, Date endDate, Long shopId, Long userId, Long headId, Integer month,String level) {
        Map m;
        if (month == null) {
            m = recordService.sumByMonth(startDate, endDate, shopId, userId, headId, level);
        } else {
            m = recordService.sumByShop(month, shopId, userId, headId, level);
        }
        return R.ok(m);
    }


}
